/*
 * =====================================================================================
 *
 *       Filename:  regex_test.c
 *
 *    Description:  
 *
 *        Version:  1.0
 *        Created:  07/04/15 00:05:42
 *       Revision:  none
 *       Compiler:  gcc
 *
 *         Author:  Andy (gk), andy_y_li@163.com
 *        Company:  RD
 *
 * =====================================================================================
 */

#include<stdio.h>
#include "str_regex.h"
#include<memory.h>
#include<stdlib.h>

int main(){

    char *bematch = "hhhericchd@gmail.com";
    //char *pattern = "h{3,10}(.*)@.{5}.(.*)";
    char *pattern = "hhhericc";
    regmatch_t pmatch[10];
    char match[100];

    PatternErrorCode status = get_pattern(bematch, pattern, pmatch, 10);
    if (status == OK) {
        for(int i=0;i<10 && pmatch[i].rm_so!=-1;i++){
            int len = pmatch[i].rm_eo-pmatch[i].rm_so;
            if(len){
                memset(match,'\0',sizeof(match));
                memcpy(match,bematch+pmatch[i].rm_so,len);
                printf("[%d]:%s\n", i, match);
            }
        }
    }
    return 0;
}

